<template>
	<view class="xilu">
		<view class="container">
			<view class="plr30 ptb30">
				<view class="xilu_box">
					<template v-if="list.length > 0">
						<view class="xilu_item flex-box" v-for="(vo,index) in list">
							<image v-if="index <= 2" :src="'../../static/images/xilu_top'+(index + 1)+'.png'" mode="aspectFill" class="xilu_item_left"></image>
							<view  v-else class="xilu_item_left">{{index + 1}}</view>
							<image :src="vo.staff.xilufitness_urls.staff_avatar || '../../static/images/avatar.png'" mode="aspectFill" class="ico120 ml30">
							</image>
							<view class="flex-grow-1 pl30">
								<view class="m-ellipsis fs34 fw500 col3 lh36">{{vo.staff.staff_name || vo.user.mobile}}</view>
								<view class="col2 fs30 lh42 mt30">{{vo.total_account || 0}}元</view>
							</view>
								<view class="flex-grow-1 pl10">
									<view class="m-ellipsis fs34 fw500 col3 lh36">{{vo.staff.area_name || ''}}</view>
								</view>
						</view>
					</template>
					<template v-else>
						<empty-data :tips="'暂无业绩排名'" :lineHeight="100"></empty-data>
					</template>

				</view>
			</view>
		</view>
	</view>
</template>

<script>
	
	var eventChannel = null;
	export default {
		data() {
			return {
				coachInfo: null,
				list: [],
				page: 1,
				total_count: 0
			}
		},
		methods: {
			//获取学员排名
			getStudentList(coach_id) {
				let _this = this;
				this.$http({
					url: '/addons/xilufitness/staff/getGoldRanking',
					method: 'GET'
				}).then(res => {
					if (res.code == 1) {
					
							_this.list = res.data.list;
						
					
					}
				}).catch(error => {
					console.log('studentRankingError', error);
				})
			}

		},
		onLoad() {
			let _this = this;
			eventChannel = this.getOpenerEventChannel();
			eventChannel.on("coachData", function(params) {
				_this.coachInfo = params.coachInfo || '';
				_this.getStudentList(_this.coachInfo.id || 0);
			});
		},
		onReachBottom() {
			if (this.total_count > this.list.length) {
				this.page = this.page + 1;
				this.getStudentList(this.coachInfo.id || 0);
			}
		},
		onShareAppMessage() {
		
		}
	}
</script>

<style lang="scss" scoped>
	.xilu {
		&_box {
			background: #fff;
			border-radius: 20rpx;
			padding: 30rpx;
		}

		&_item {
			width: 630rpx;
			height: 200rpx;
			background: #E8EEFE;
			border-radius: 20rpx;
			padding-left: 30rpx;
			padding-right: 30rpx;

			&_left {
				width: 40rpx;
				height: 40rpx;
				line-height: 40rpx;
				text-align: center;
				font-size: 28rpx;
				font-weight: 500;
				color: #333;
			}
		}

		&_item+&_item {
			margin-top: 30rpx;
		}

		&_foot_nav {
			width: 750rpx;
			height: 200rpx;
			background: #585A5C;
			padding-left: 90rpx;
			padding-right: 90rpx;
		}
	}

	.ico120 {
		width: 120rpx;
		height: 120rpx;
		border-radius: 50%;

	}

	.pb120 {
		padding-bottom: 120rpx;
	}
</style>